package com.htthorizon;

import com.htthorizon.common.core.web.domain.AjaxResult;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.sql.SQLIntegrityConstraintViolationException;

/**
 * @author Brilliant
 */
@RestControllerAdvice
public class GlobalException {

    @ExceptionHandler(value = SQLIntegrityConstraintViolationException.class)
    public AjaxResult exception(Exception e) {
        if (e.getMessage().contains("uni_table")){
            return AjaxResult.error("英文表名已被使用");
        }
        return AjaxResult.error("模型名称已被使用");
    }
}
